persistent database connection - Apache::DBI with mod_perl
am 16.07.2008 07:58:19 von Chris Zhuang--0-1480779522-1216187899=:73831
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hi,
Â
I have problems to setup persistent database connection for my perl project=
using mod_perl.
Â
It tooks me two days which i still cann't figure out how mod_perl works wit=
h Apache::DBI.
Â
My Server Settings:
ActiveState Perl 5.8.8 build 822
Apache HTTP Server 2.2.9
Apache DBI 1.06
mod_perl 2.03
DBD-Oracle 1.17
Â
--------------Adding to httpd.conf--------------
Â
LoadFile "C:/Perl/bin/perl58.dll"
LoadModule perl_module modules/mod_perl.so
PerlSetEnv DBI_TRACE "3=3DC:/Perl/dbitrace.log"
PerlModule Apache::DBI
PerlRequire "C:/Perl/lib/startup.pl"
Â
--------------End-------------------------------------
Â
--------------startup.pl--------------
#!c:/perl/bin/perl.exe=20
$ENV{MOD_PERL} or die "GATEWAY_INTERFACE not Perl!";
#use Apache::Registry;
use Apache::DBI;
use strict;
$Apache::DBI::DEBUG =3D 2;
Apache::DBI->connect_on_init("dbi:Oracle:host=3Dxxx;sid=3Dxx x",
            =C2=
           Â=A0=
   "xxx", "xxx",
            =C2=
           Â=A0=
   {PrintError =3D> 1, RaiseError =3D> 0, AutoCommit =3D> 1=
,}
            =C2=
           Â=A0=
   );
Â
my $timeout =3D 0;
Apache::DBI->setPingTimeOut("dbi:Oracle:host=3Dxxx;sid=3Dxxx ", $timeout);
Â
1;
--------------End-------------------------------------
Â
--------------Apache Startup Log-------------------------------------
[Wed Jul 16 14:43:54 2008] [notice] Apache/2.2.9 (Win32) mod_perl/2.0.3 Per=
l/v5.8.8 configured -- resuming normal operations
[Wed Jul 16 14:43:54 2008] [notice] Server built: Jun 13 2008 04:04:59
[Wed Jul 16 14:43:54 2008] [notice] Parent: Created child process 996
[Wed Jul 16 14:43:54 2008] [notice] Child 996: Child process is running
996 Apache::DBIÂ Â Â Â Â Â Â Â = C2 Â=A0=
  PerlChildInitHandler
996 Apache::DBIÂ Â Â Â Â Â Â Â = C2 Â=A0=
  need ping: yes
996 Apache::DBIÂ Â Â Â Â Â Â Â = C2 Â=A0=
  new connect to 'host=3Dxxx;sid=3Dxxx=1Cxxx=1Cxxx=1CAutoCommit=
=3D1=1CPrintError=3D1=1CRaiseError=3D0=1CUsername=3Dxxx'
[Wed Jul 16 14:43:55 2008] [notice] Child 996: Acquired the start mutex.
[Wed Jul 16 14:43:55 2008] [notice] Child 996: Starting 64 worker threads.
[Wed Jul 16 14:43:55 2008] [notice] Child 996: Starting thread to listen on=
port 80.
--------------End-------------------------------------
I can see it sucessful open the oracle DB connection.
Â
However, when I run an CGI script on the IE 6, it cannot find $ENV{MOD_PERL=
} and start new DBI connection.
Â
--------foo.cgi--------------------
#!c:/perl/bin/perl.exe -d
use DBI;
use CGI qw(:standard);
my $dbh =3D DBI->connect("dbi:Oracle:host=3Dxxx;sid=3Dxxx",
            =C2=
           Â=A0=
   "xxx", "xxx",
            =C2=
           Â=A0=
   {PrintError =3D> 1, RaiseError =3D> 0, AutoCommit =3D> 1=
,}
            =C2=
           Â=A0=
   );
--------END--------------------
Â
Do I need to do any setting in Apache for $ENV{MOD_PERL}?=20
Did I do any thing wrong in above code?
Â
Thanks and Regards
Â
Chris Z
=0A Start at the new Yahoo!7 for a better online experien=
ce. www.yahoo7.com.au
--0-1480779522-1216187899=:73831
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
top' style=3D'font: inherit;'> |
=0AStart=
at the new Yahoo!7 for a better online experience - d.yahoo.com/mail/taglines/au/y7mail/default/*http://au.docs. yahoo.com/somet=
hingwonderful/index.php?p1=3Dbrand&p2=3Dother&p3=3Dau&p4=3Dt agline" target=
=3D_blank>Start Here.
--0-1480779522-1216187899=:73831--